package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceChargeReturn;
import com.ruoyi.service.service.IServiceChargeReturnService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 退费记录Controller
 * 
 * @author yepanpan
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/service/chargeReturn")
public class ServiceChargeReturnController extends BaseController
{
    @Autowired
    private IServiceChargeReturnService serviceChargeReturnService;

    /**
     * 查询退费记录列表
     */
    @PreAuthorize("@ss.hasPermi('service:chargeReturn:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceChargeReturn serviceChargeReturn)
    {
        startPage();
        List<ServiceChargeReturn> list = serviceChargeReturnService.selectServiceChargeReturnList(serviceChargeReturn);
        return getDataTable(list);
    }

    /**
     * 导出退费记录列表
     */
    @PreAuthorize("@ss.hasPermi('service:chargeReturn:export')")
    @Log(title = "退费记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceChargeReturn serviceChargeReturn)
    {
        List<ServiceChargeReturn> list = serviceChargeReturnService.selectServiceChargeReturnList(serviceChargeReturn);
        ExcelUtil<ServiceChargeReturn> util = new ExcelUtil<ServiceChargeReturn>(ServiceChargeReturn.class);
        util.exportExcel(response, list, "退费记录数据");
    }

    /**
     * 获取退费记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:chargeReturn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serviceChargeReturnService.selectServiceChargeReturnById(id));
    }

    /**
     * 新增退费记录
     */
    @PreAuthorize("@ss.hasPermi('service:chargeReturn:add')")
    @Log(title = "退费记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody ServiceChargeReturn serviceChargeReturn)
    {
                serviceChargeReturn.setCreateBy(getUsername());
        return toAjax(serviceChargeReturnService.insertServiceChargeReturn(serviceChargeReturn));
    }

    /**
     * 修改退费记录
     */
    @PreAuthorize("@ss.hasPermi('service:chargeReturn:edit')")
    @Log(title = "退费记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody ServiceChargeReturn serviceChargeReturn)
    {
                serviceChargeReturn.setUpdateBy(getUsername());
        return toAjax(serviceChargeReturnService.updateServiceChargeReturn(serviceChargeReturn));
    }

    /**
     * 删除退费记录
     */
    @PreAuthorize("@ss.hasPermi('service:chargeReturn:remove')")
    @Log(title = "退费记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceChargeReturnService.deleteServiceChargeReturnByIds(ids));
    }
}
